//
//  DataModel.m
//  CoolRollerSkating
//
//  Created by 谢伟康 on 15/11/9.
//  Copyright © 2015年 Coollang. All rights reserved.
//

#import "DataModel.h"

@implementation DataModel

+ (void)saveAppVersion:(NSString *)version
{
    [[NSUserDefaults standardUserDefaults] setObject:version forKey:@"version"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSString *)storeAppVersion
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"version"];
}

+ (void)saveLastLoginAccountID:(NSString *)accountID
{
    [[NSUserDefaults standardUserDefaults] setObject:accountID forKey:@"lastLoginID"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSString *)lastLoginID
{
    return [[NSUserDefaults standardUserDefaults] stringForKey:@"lastLoginID"];
}

+ (BOOL)shouldAutoLogin
{
    BOOL autoLogin = [[NSUserDefaults standardUserDefaults] boolForKey:@"hasLogin"];
    
    return autoLogin;
}

+ (void)setAutoLogin:(BOOL)hasLogin
{
    [[NSUserDefaults standardUserDefaults] setBool:hasLogin forKey:@"hasLogin"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)saveLastUUIDString:(NSString *)uuidString
{
    [[NSUserDefaults standardUserDefaults] setObject:uuidString forKey:@"UUIDString"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (NSString *)lastUUIDString
{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"UUIDString"];
}

+ (void)setIsHaveHistory:(BOOL)isHaveHistory {
    
    [[NSUserDefaults standardUserDefaults] setBool:isHaveHistory forKey:@"isHaveHistoryData"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (BOOL)isHaveHistoryData {
    return [[NSUserDefaults standardUserDefaults] boolForKey:@"isHaveHistoryData"];
}


+ (NSString *)writeAndReadRealTimeTargetpathString {
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
       // 根据主键设置存储路径
   
    path = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"RealTimeTrainTarget_%@.data",[DataModel lastLoginID]]];
 
    
    return path;
}

+ (NSString *)writeAndReadRealTimeTrainDataPathString {
    
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
    path = [path stringByAppendingPathComponent:[NSString stringWithFormat:@"realTimeTrain_%@.data",[DataModel lastLoginID]]];
    return path;
}

/** 保存最新的获取正反手训练的上传时间戳 */
+ (void)saveLastRealTimeGetHBUploadTime:(NSString *)lastHBUploadTime {
    [[NSUserDefaults standardUserDefaults] setObject:lastHBUploadTime forKey:@"lastHBUploadTime"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSString *)lastHBUploadTime {
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"lastHBUploadTime"];
}
/** 保存最新的获取发球训练的上传时间戳 */
+ (void)saveLastRealTimeGetFQUploadTime:(NSString *)lastFQUploadTime {
    [[NSUserDefaults standardUserDefaults] setObject:lastFQUploadTime forKey:@"lastFQUploadTime"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
+ (NSString *)lastFQUploadTime {
     return [[NSUserDefaults standardUserDefaults] objectForKey:@"lastFQUploadTime"];
}

/** 实时训练是否开启声音 */
+ (void)setRealTimeSound:(BOOL)open {
    [[NSUserDefaults standardUserDefaults] setBool:open forKey:@"RealTimeSound"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (BOOL)lastRealTimeSound {
    return [[NSUserDefaults standardUserDefaults] boolForKey:@"RealTimeSound"];
}

@end
